<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>socket.d debug</title>
    <script src="socketd/dist/socketd.js"></script>
</head>
<body>
<script type="text/javascript">
    let serverUrl = "sd:ws://127.0.0.1:8062";

    window.onload = async function() {
        window.client = SocketD.createClient(serverUrl)
            .listen(new EventListener().doOnOpen(s => {
                //成功连接到服务器
                client.send("1111")
            }).doOnMessage((s, m) => {
                //服务器发送通知
                //开始处理
                document.getElementById("rst").append("message received: " + e.data + "\n");
            })
                .doOnClose(s => {

                }))
            .open();
    };

    function send() {
        var msg = document.getElementById('message').value;
        window.client.send(msg);
    }

</script>
<h1>WebSocket Echo Test</h1>
<form>
    <p>
        Message: <input id="message" type="text" value="Hello, world!">
    </p>
</form>
<button onclick="send();">Send Message</button>
<div id="rst">

</div>

</body>
</html>